package com.xs.project.utils;

import java.text.SimpleDateFormat;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Date;

public class DateUtil {
    public static String getDateStr(Date date){
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
        return sdf.format(date);
    }

    public static Date getDate(String dateStr){
        try {

            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
            return sdf.parse(dateStr);
        }catch (Exception e){

        }
        return null;
    }

    public static void main(String[] args) {
        String str = "2024-08-18T16:00:00.000Z";
        System.out.println(getDate(str));
    }
}
